home *** CD-ROM | disk | FTP | other *** search
- /*
- *=============================================================================
- * tSippInt.h
- *-----------------------------------------------------------------------------
- * Internal, global declarations for Tcl SIPP interface.
- *-----------------------------------------------------------------------------
- * Copyright 1992 Mark Diekhans
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies. Mark Diekhans makes
- * no representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *-----------------------------------------------------------------------------
- * $Id: tSippInt.h,v 2.0 1992/11/02 03:56:16 markd Rel $
- *=============================================================================
- */
-
- #include <malloc.h>
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- #include <memory.h>
-
- #include "tclExtend.h"
- #include "sipp.h"
- #include "shaders.h"
- #include "primitives.h"
-
- /*
- * Version suffix for tsipp. It is append to the SIPP version to identify
- * the version number for tsipp. Also a variable that will contain the
- * full version string, including patch level.
- */
- #define TSIPP_VERSION_SUFFIX "a"
-
- extern char *TSIPP_VERSION;
-
- /*
- * Global Tcl SIPP structure. It is the client data to all commands.
- */
-
- typedef struct {
- Tcl_Interp *interp; /* Tcl interpreter pointer. */
- bool showBackFaces; /* Render or draw backfaceing polys. */
- Color backgroundColor; /* Current background color. */
- Color lineColor; /* Color for lines in RLE LINE render */
- void_pt surfaceTblPtr; /* Surface table. */
- void_pt objectTblPtr; /* Object table. */
- void_pt shaderTblPtr; /* Shader table. */
- void_pt lightTblPtr; /* Light table. */
- void_pt cameraTblPtr; /* Camera table. */
- void_pt rleTblPtr; /* RLE file table. */
- } tSippGlob_t, *tSippGlob_pt;
-
- /*
- * Type used to pass parser rendering parameters.
- */
- typedef struct {
- char *fileHandle; /* Ptr to file handle in argv. */
- unsigned xSize; /* Size of image to render. */
- unsigned ySize;
- unsigned mode; /* FLAG, GOURAUD, PHONG or LINE. */
- unsigned overSampling; /* Oversampling factor. */
- bool interlaced; /* Interlaced (field) rendering. */
- int field; /* ODD or EVEN scan lines. */
- } tSippRenderParms_t, *tSippRenderParms_pt;
-
- /*
- * Type used in initializing Tcl commands.
- */
- typedef struct {
- char *name;
- Tcl_CmdProc *proc;
- } tSippTclCmdTbl_t;
-
- /*
- * Type used to store a translated handle list. A static array is used
- * unless the list is bigger, then it goes dynamic.
- */
- #define HANDLE_LIST_STATIC_SIZE 16
-
- typedef struct {
- void **ptr;
- int len;
- void *staticArray [HANDLE_LIST_STATIC_SIZE];
- } handleList_t, *handleList_pt;
-
- /*
- * Macros to do string compares. They pre-check the first character before
- * checking of the strings are equal.
- */
-
- #define STREQU(str1, str2) \
- (((str1) [0] == (str2) [0]) && (strcmp (str1, str2) == 0))
- #define STRNEQU(str1, str2, cnt) \
- (((str1) [0] == (str2) [0]) && (strncmp (str1, str2, cnt) == 0))
-
- /*
- * Macros to handle dealing with numbers that may have encountered a round
- * off error:
- * FZERO - Is the number zero, with in the tolerance.
- * FZERO_ROUND - Round the number to zero, if its in the tolerance of zero.
- * FEQUAL - Is the number equal, within the tolerance.
- *
- */
- #define TOLERANCE 1e-13
- #define FZERO(f) ((f) < TOLERANCE && (f) > -TOLERANCE)
- #define FZERO_ROUND(f) (FZERO(f) ? 0.0 : (f))
- #define FEQUAL(f1, f2) ((((f2) - TOLERANCE) < (f1)) && \
- ((f1) < (((f2) + TOLERANCE))))
-
- /*
- * WARNING: This is an internal Tcl data structure and function. It might
- * change. John needs to export this fucntion.
- */
- typedef struct OpenFile {
- FILE *f;
- FILE *f2;
- int readable;
- int writable;
- int numPids;
- int *pidPtr;
- int errorId;
- } OpenFile;
-
- extern int
- TclGetOpenFile _ANSI_ARGS_((Tcl_Interp *interp,
- char *string,
- OpenFile **filePtrPtr));
-
-
- /*
- * tSippUtil.c externals.
- */
- bool
- TSippConvertFraction _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *strBuf,
- double *valuePtr));
-
- bool
- TSippConvertUnsignedDbl _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *strBuf,
- double *valuePtr));
-
- bool
- TSippConverPosUnsigned _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *strBuf,
- unsigned *valuePtr));
-
- bool
- TSippConvertColor _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *listStr,
- Color *colorPtr));
-
- bool
- TSippConvertOpacity _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *listStr,
- Color *opacityPtr));
-
- bool
- TSippConvertAngleRad _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *strBuf,
- double *valuePtr));
-
- bool
- TSippConvertAngleDeg _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *strBuf,
- double *valuePtr));
-
- bool
- TSippConvert2DPoint _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *listStr,
- double *xCoordPtr,
- double *yCoordPtr));
-
- bool
- TSippConvertVertex _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *listStr,
- Vector *vertexPtr));
-
- bool
- TSippConvertVertexTex _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *listStr,
- Vector *vertexPtr,
- Vector *texturePtr));
-
- bool
- TSippConvertMatrix _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *listStr,
- Transf_mat *matrixPtr));
-
- char *
- TSippFormatMatrix _ANSI_ARGS_((Transf_mat *matrixPtr));
-
- bool
- TSippHandleListConvert _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- void *handleTblPtr,
- char *listPtr,
- handleList_pt handleListPtr,
- handleList_pt handleEntryListPtr));
-
- void
- TSippHandleListFree _ANSI_ARGS_((handleList_pt handleListPtr));
-
- void
- TSippInitCmds _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- tSippTclCmdTbl_t *cmdTablePtr));
-
- bool
- TSippParseRenderParms _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- int argc,
- char **argv,
- char *fileTitle,
- tSippRenderParms_pt renderParmsPtr));
-
- bool
- TSippParseTextureMapping _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *textureStr,
- int *texturePtr,
- int *invalidList));
-
- void
- TSippInitialize _ANSI_ARGS_((Tcl_Interp *interp));
-
- /*
- * tSippBezier.c externals.
- */
- void
- TSippBezierInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-
- /*
- * tSippPoly.c externals.
- */
- Surface *
- TSippSurfaceHandleToPtr _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *handle));
-
- void
- TSippPolyInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-
- /*
- * tSippObj.c externals.
- */
- void
- TSippBindObjectToHandle _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- Object *objectPtr));
-
- Object *
- TSippObjectHandleToPtr _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *handle));
-
- void
- TSippObjectInit _ANSI_ARGS_((tSippGlob_pt tclSippGlobP));
-
- /*
- * tSippLight.c externals.
- */
- void
- TSippLightInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-
- /*
- * tSippCamera.c externals.
- */
- void
- TSippCameraInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-
- /*
- * tSippShader.c externals.
- */
- Shader *
- TSippShaderHandleToPtr _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr,
- char *handle,
- void **surfDescPtrPtr));
-
- void
- TSippShaderInit _ANSI_ARGS_((tSippGlob_pt tclSippGlobP));
-
- /*
- * tSippPrim.c externals.
- */
- void
- TSippPrimInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-
- /*
- * tSippPPM.c externals.
- */
- void
- TSippPPMInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-
- /*
- * tSippRLE.c externals.
- */
- void
- TSipp_RLEInit _ANSI_ARGS_((tSippGlob_pt tSippGlobPtr));
-